export default {
  props: {
    config: {
      type: Object,
    },
    count: {
      type: Number,
    },
	complex: {
		type: Object
	},
  },
  watch: {
    // config: {
    // 	deep: true,
    // 	immediate: true,
    // 	handler(val,oldVal) {
    // 		this._initAttr()
    // 		console.log(val,'---',oldVal);
    // 		// if(val.id!=oldVal.id){
    // 		// 	this._initAttr()
    // 		// }
    // 	},
    // },
    count: {
      handler() {
        this._initAttr();
      },
      immediate: true,
    },
  },
  created() {
    // 请求数据
  },
  methods: {
    _initAttr() {
      try {
        let data = {};
        if (this.config.config.hasOwnProperty("attr")) {
          this.config.config.attr.forEach((item) => {
            data[item.key] = item.data;
          });
          this.attr = data;
        }
        if (this.config.config.hasOwnProperty("data")) {
          if (this.config.config.data.type === "defaulteVal") {
            this[this.config.config.data.key] = this.config.config.data.value;
          }
        }
      } catch (e) {
        //TODO handle the exception
      }
    },
  },
};
